#include "OiPCH.hpp"

namespace Oi
{
    namespace PLScannerDll
    {
        using namespace PLScannerCore;

        class PageAbstractImpl : public Impl<PageAbstract>
        {
        public:
            bool _run;
        };

        PageAbstract::PageAbstract(QWidget * parent /*= nullptr*/)
            : QWidget(parent)
        {
            OI_I(PageAbstract);
            d->_run = false;
        }

        void PageAbstract::addResult(const WorkResult::Result& result)
        {
            OI_F(PageAbstract);
            //if (d->_run)
            {
                setResult(result);
            }
        }

        void PageAbstract::run(bool flag)
        {
            OI_F(PageAbstract);
            d->_run = flag;

            if (isVisible() && d->_run)
            {
                setRun(true);
            }
            else
            {
                setRun(false);
            }
        }

        void PageAbstract::showEvent(QShowEvent *event)
        {
            OI_F(PageAbstract);

            toCurrent();

            if (d->_run)
            {
                setRun(true);
            }
        }

        void PageAbstract::hideEvent(QHideEvent *event)
        {
            setRun(false);
        }

        void PageAbstract::updatePermission()
        {
            return;
        }

    }
}